package com.back.model.reslut;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

@Data
public class Result<T> {
    private Integer code;
    private T data;
    private String msg;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String token;


    public static <T> Result<T> success() {
        Result<T> result = new Result<T>();
        result.code = 0;
        return result;
    }
    public static <T> Result<T> successMessage(String msg) {
        Result<T> result = new Result<T>();
        result.code = 0;
        result.msg = msg;
        return result;
    }
    public static <T> Result<T> successData(T data) {
        Result<T> result = new Result<T>();
        result.code = 0;
        result.data = data;
        return result;
    }



    public static <T> Result<T> success(T data, String msg) {
        Result<T> result = new Result<T>();
        result.code = 0;
        result.data = data;
        result.msg = msg;
        return result;
    }

    public static <T> Result<T> faile(String msg) {
        Result<T> result = new Result<T>();
        result.code = 1;
        result.msg = msg;
        return result;
    }
    public static <T> Result<T> faile(Integer code,String msg) {
        Result<T> result = new Result<T>();
        result.code = code;
        result.msg = msg;
        return result;
    }
}